<?php
	use yii\helpers\Html;
	use yii\helpers\Url;
	use yii\widgets\ActiveForm;
	use yii\widgets\LinkPager;
?>
<style>
	.status-1 {
		background-color: #999;
	}
	.status-2 {
		background-color: #FFF;
	}
	.status-3 {
		background-color: #FF0;
	}
	.status-4 {
		background-color: #06F;
	}
	.status-5 {
		background-color: #C00;
	}
</style>
<div class="page-header">
	<h1>
		房源管理
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			详细信息
		</small>
	</h1>

</div><!-- /.page-header -->

<!-- PAGE CONTENT BEGINS -->
<div class="row">
	<div class="col-xs-12">
		<div class="tabbable">
			<ul class="nav nav-tabs" id="myTab">
				<li class="active">
					<a data-toggle="tab" href="#home">
						<i class="green ace-icon fa fa-home bigger-120"></i>
						房间资料
					</a>
				</li>

				<li>
					<a data-toggle="tab" href="#messages">
						房贷计算器
					</a>
				</li>

				<li >
					<a data-toggle="tab" class="dropdown-toggle" href="#kong">
						房间销控 &nbsp;
					</a>
				</li>
			</ul>

			<div class="tab-content">
				<div id="home" class="tab-pane fade in active">
					<table id="simple-table" class="table table-striped table-bordered table-hover">

						<tbody>
							<tr>
								<td width="12%">地&#12288;&#12288;址：</td>
								<td><?php echo $floor.'栋'.$model['unitNo'].'单元'.$model['roomId'].'室';?></td>
								<td width="12%">房间型号：</td>
								<td><?php echo $model['item'];?></td>
								<td width="12%">身份证号</td>
								<td><?php echo isset($model['sid'])?$model['sid']:'';?></td>
							</tr>
							<tr>
								<td>销售状态：</td>
								<td>
									<?php if($model['status']==1):?>
										<span class="status-1">保留</span>
									<?php endif;?>	
									<?php if($model['status']==2||$model['status']==0):?>
										<span class="status-2">可售</span>
									<?php endif;?>
									<?php if($model['status']==3):?>
										<span class="status-3">销控</span>
									<?php endif;?>
									<?php if($model['status']==4):?>
										<span class="status-4">认购</span>
									<?php endif;?>
									<?php if($model['status']==5):?>
										<span class="status-5">签约</span>
									<?php endif;?>
								</td>
								<td>建筑面积：</td>
								<td><?php echo $model['area'];?></td>
								<td>成交单价：</td>
								<td><?php echo $model['dealprice'];?></td>
							</tr>
							<tr>
								<td>套内面积：</td>
								<td><?php echo $model['inarea'];?></td>
								<td>原始定价：</td>
								<td><?php echo $model['price'];?></td>
								<td>成交总价：</td>
								<td><?php echo $model['dealTotalprice'];?></td>
							</tr>
							<tr>
								<td>朝&#12288;&#12288;向：</td>
								<td><?php echo $model['toWard'];?></td>
								<td>户&#12288;&#12288;型：</td>
								<td><?php echo $model['houseType'];?></td>
								<td>原始单价：</td>
								<td><?php echo $model['totalPrice'];?></td>
							</tr>
							<tr>
								<td>业主姓名：</td>
								<td><?php echo isset($model['owner'])?$model['owner']:'';?></td>
								<td>认购时间：</td>
								<td><?php echo date('Y-m-d',$model['addTime']);?></td>
								<td>跟办顾问：</td>
								<td><?php echo $master;?></td>
							</tr>
							<tr>
								<td>享受优惠：</td>
								<td></td>
							</tr>
						</tbody>
						
					</table>
				</div>
				<div id="messages" class="tab-pane fade">

					<table id="simple-table" class="table table-striped table-bordered table-hover">
						<tbody>
							<tr>
								<td width="12%">总&#12288;&#12288;价：</td>
								<td><input type="text" id="J_Total">元</td>
								<td width="12%">贷款总额</td>
								<td id="J_Daitotal"></td>
								
							</tr>
							<tr>
								<td width="12%">按揭成数：</td>
								<td><input type="text" id= "J_Dai">成</td>
								<td width="12%">首期房款</td>
								<td id="J_Shou"></td>
							</tr>
							<tr>
								<td width="12%">贷款年限：</td>
								<td><input type="text" id="J_Year">年</td>
								<td width="12%">每月还款</td>
								<td id='J_Mdai'></td>
							</tr>
							<tr >
								<td width="12%">银行利率：</td>
								<td>
									<select name="" id="J_Lilv">
										<option value="0.049">最新基准利率</option>
							    		<option value="0.0539">最新基准利率1.1倍</option>
							    		<option value="0.04165">最新基准利率8.5折</option>
							    		<option value="0.0392">最新基准利率8折</option>
									</select>%
								</td>
								<td width="12%">利息总计</td>
								<td id="J_Litotal"></td>
							</tr>
						</tbody>
					</table>

					<div class="clearfix">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-info" id="J_Sub">
								<i class="ace-icon fa fa-check bigger-110"></i>
								提交
							</button>

							&nbsp; &nbsp; &nbsp;
							<button class="btn" id="J_Rset">
								<i class="ace-icon fa fa-undo bigger-110"></i>
								重置
							</button>
						</div>
					</div>

				</div>

				<div id="kong" class="tab-pane fade">
					<table id="simple-table" class="table table-striped table-bordered table-hover">
						<tbody>
							<tr>
								<td width="12%">销售顾问：</td>
								<td><?php echo $master;?></td>								
							</tr>
							<tr>
								<td width="12%">筹&#12288;&#12288;号：</td>
								<td><input type="text"></td>
							</tr>
							<tr>
								<td width="12%">备&#12288;&#12288;注：</td>
								<td width="60%"><textarea col="30"></textarea></td>				
							</tr>
						</tbody>
					</table>
					<div class="clearfix">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-info" id="J_Sub">
								<i class="ace-icon fa fa-check bigger-110"></i>
								销控
							</button>
						</div>
					</div>
				</div>


			</div>
		</div>
			
	</div><!-- /.span -->
</div><!-- /.row -->
<script src="./ace/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
	function del(id){
		if(window.confirm('确认要删除么?')){
			window.location.href = "<?php echo Url::toRoute(['content/del'])?>&id="+id;
		}
	}

	$("#J_Sub").on('click',function(){
		var total = $("#J_Total").val();
		var dai = $("#J_Dai").val();
		var year = $("#J_Year").val();
		var lv = $("#J_Lilv").val();
		if(total.length==0){  
     		alert("总价不能为空");
     		return;
		} 
		if(dai.length==0){  
     		alert("按揭成数不能为空");
     		return;
		}
		if(year.length==0){  
     		alert("贷款年限不能为空");
     		return;
		}
		if(lv.length==0){  
     		alert("银行利率不能为空");
     		return;
		}
		$.ajax({
    		type:'post',
    		url:'<?= Url::to(['room/dai'])?>',
    		data:{_csrf:'<?= Yii::$app->request->csrfToken?>',total:total,dai:dai,year:year,lv:lv},		    		       				
    		success:function(response){
                var data = JSON.parse(response);
    			console.log(data['daitotal']);
    			$("#J_Daitotal").html(data['daitotal'].toFixed(2));
    			$("#J_Shou").html(data['shoutotal'].toFixed(2));
    			$("#J_Mdai").html(data['mdai'].toFixed(2));
    			$("#J_Litotal").html(data['litotal'].toFixed(2));
    		}
    	});
	});

	$("#J_Rset").on('click',function(){
		 $("#J_Total").val("");
		 $("#J_Dai").val("");
		 $("#J_Year").val("");
		 $("#J_Lilv").val("");
	})


</script>
<div class="hr hr-18 dotted hr-double"></div>